#if !GENERATOR

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Collections.Generic;

using YF.OneNote;


namespace YF.OneNote.DataTypes
{
  using Collections;


  public partial class Section
  {
    public Section()
    {
      _pages.CollectionChanged += _pages_CollectionChanged;
	}

    
    private void _pages_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Page> e)
    {
      switch (e.Action)
      {
        case NotifyCollectionChangedAction.Add:
        {
          foreach (Page item in e.NewItems)
            Children.Add(item);
        }
          break;

        case NotifyCollectionChangedAction.Remove:
        {
          foreach (Page item in e.OldItems)
            Children.Remove(item);
        }
          break;
      }
    }

  
    protected override bool UpdateSpecificContents(NotesHierarchyNode node, List<INotesChange> changes)
    {
	  Section item = (Section)node;
      bool changed = false;

      
      if (AreAllPagesAvailable != item.AreAllPagesAvailable)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _areAllPagesAvailable;
        propertyChange.NewValue = item._areAllPagesAvailable;
        propertyChange.PropertyName = "AreAllPagesAvailable";
        changes.Add(propertyChange);

		
        _areAllPagesAvailable = item._areAllPagesAvailable;
      }

      if (Color != item.Color)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _color;
        propertyChange.NewValue = item._color;
        propertyChange.PropertyName = "Color";
        changes.Add(propertyChange);

		
        _color = item._color;
      }

      if (Encrypted != item.Encrypted)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _encrypted;
        propertyChange.NewValue = item._encrypted;
        propertyChange.PropertyName = "Encrypted";
        changes.Add(propertyChange);

		
        _encrypted = item._encrypted;
      }

      if (IsCurrentlyViewed != item.IsCurrentlyViewed)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _isCurrentlyViewed;
        propertyChange.NewValue = item._isCurrentlyViewed;
        propertyChange.PropertyName = "IsCurrentlyViewed";
        changes.Add(propertyChange);

		
        _isCurrentlyViewed = item._isCurrentlyViewed;
      }

      if (Locked != item.Locked)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _locked;
        propertyChange.NewValue = item._locked;
        propertyChange.PropertyName = "Locked";
        changes.Add(propertyChange);

		
        _locked = item._locked;
      }

      if (UpdateCollection(Pages, item.Pages, changes))
        changed = true;

      if (Path != item.Path)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _path;
        propertyChange.NewValue = item._path;
        propertyChange.PropertyName = "Path";
        changes.Add(propertyChange);

		
        _path = item._path;
      }

      if (ReadOnly != item.ReadOnly)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _readOnly;
        propertyChange.NewValue = item._readOnly;
        propertyChange.PropertyName = "ReadOnly";
        changes.Add(propertyChange);

		
        _readOnly = item._readOnly;
      }


      return changed;
    }
  }
}

#endif